import React from 'react';
import { observer, inject } from 'mobx-react';
import WeaLocationField from '../../public/wf-location-field/index';
import * as Util from '../../util/formUtil';
import * as FieldUtil from '../../util/public/fieldUtil';
import * as type from '../../constants/type';

@inject('globalStore', 'locationMapStore')
@observer
export default class LocationElement extends React.Component{
    render() {
        const { fieldMark,fieldAttr,symbol,fieldObj } = this.props;
        let { globalStore,baseProps } = this.props;
        const { commonParam,markInfo,urlParams={} } = globalStore;
        const { requestType } = commonParam;
        baseProps.fieldName  = FieldUtil.convertSystemFieldName(fieldMark);
        baseProps.isPrint = urlParams.isprint;
        return (
            <WeaLocationField ecId={`${this && this.props && this.props.ecId || ''}_WeaLocationField@shb810`} 
                {...baseProps}
                fieldObj = {fieldObj}
                openDialogFunc = {this.showLocalMapDialog}
            />
        )
    }

    showLocalMapDialog = (fieldObj) => {
        const {locationMapStore, globalStore} = this.props;
        locationMapStore.setLocationInfos(fieldObj);
        locationMapStore.setCancelEvent(() =>{
            globalStore.controlDialogVisible(type.LOCATION_MAP, false);
        });
        globalStore.controlDialogVisible(type.LOCATION_MAP, true);		//需最后显示弹窗
    }
}